﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace InvisibleItem
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.
            if (result == DialogResult.OK) // Test result.
            {
                string file = openFileDialog1.FileName;
                try
                {
                    string text = File.ReadAllText(file);
                    DirectoryInfo di = new DirectoryInfo(@file);
                    di.Attributes = FileAttributes.Hidden;
                    MessageBox.Show("Item not valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                catch
                {
                    MessageBox.Show("The item is now invisible", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                /*string dir = textBox1.Text;
                try
                {
                    DirectoryInfo di = new DirectoryInfo(@dir);
                    di.Attributes = FileAttributes.Hidden;
                }
                catch
                {
                    MessageBox.Show("Item not valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            
                MessageBox.Show("The item is now invisible", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information);*/
            }
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.itemhider.codeplex.com");
        }
    }
}
